package com.zivwu.utils.model;


import android.os.Parcel;
import android.os.Parcelable;

import androidx.annotation.NonNull;


public class Photo implements Comparable<Photo>, Parcelable {
    private String bucket_display_name;
    private int _id;
    private String data;//path
    private String display_name;
    private String mime_type;
    private int date_modified;
    private boolean isChecked;

    protected Photo(Parcel in) {
        bucket_display_name = in.readString();
        _id = in.readInt();
        data = in.readString();
        display_name = in.readString();
        mime_type = in.readString();
        date_modified = in.readInt();
        isChecked = in.readInt() != 0;
    }

    public static final Creator<Photo> CREATOR = new Creator<Photo>() {
        @Override
        public Photo createFromParcel(Parcel in) {
            return new Photo(in);
        }

        @Override
        public Photo[] newArray(int size) {
            return new Photo[size];
        }
    };

    public int getDate_modified() {
        return date_modified;
    }

    public void setDate_modified(int date_modified) {
        this.date_modified = date_modified;
    }

    public String getBucket_display_name() {
        return bucket_display_name;
    }

    public void setBucket_display_name(String bucket_display_name) {
        this.bucket_display_name = bucket_display_name;
    }

    public int get_id() {
        return _id;
    }

    public void set_id(int _id) {
        this._id = _id;
    }

    public String getData() {
        return data;
    }

    public void setData(String data) {
        this.data = data;
    }

    public String getDisplay_name() {
        return display_name;
    }

    public void setDisplay_name(String display_name) {
        this.display_name = display_name;
    }

    public String getMime_type() {
        return mime_type;
    }

    public void setMime_type(String mime_type) {
        this.mime_type = mime_type;
    }


    public boolean isChecked() {
        return isChecked;
    }

    public void setChecked(boolean checked) {
        isChecked = checked;
    }

    public Photo(String bucket_display_name, int _id, String data, String display_name, String mime_type, int date_modified) {
        this.bucket_display_name = bucket_display_name;
        this._id = _id;
        this.data = data;
        this.display_name = display_name;
        this.mime_type = mime_type;
        this.date_modified = date_modified;
    }

    public Photo(String data) {
        this.data = data;
    }

    @Override
    public String toString() {
        return "Photo{" +
                "bucket_display_name='" + bucket_display_name + '\'' +
                ", _id=" + _id +
                ", data='" + data + '\'' +
                ", display_name='" + display_name + '\'' +
                ", mime_type='" + mime_type + '\'' +
                ", date_modified='" + date_modified + '\'' +
                '}';
    }




    @Override
    public int compareTo(@NonNull Photo o) {


        if (this.date_modified == o.getDate_modified())
            return 0;
        return date_modified > o.getDate_modified() ? 1 : -1;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(bucket_display_name);
        dest.writeInt(_id);
        dest.writeString(data);
        dest.writeString(display_name);
        dest.writeString(mime_type);
        dest.writeInt(date_modified);
        dest.writeInt((isChecked ? 1 : 0));
    }
}
